package edu.xidian.bdilab.jrbigdata.controller.enterprise;

import edu.xidian.bdilab.jrbigdata.controller.response.ResponseResult;
import edu.xidian.bdilab.jrbigdata.service.enterprise.productRequest.ProductRequestService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * @ClassName ProductRequestController
 * @Description TODO
 * @Author tuantuan
 * @Date 2019/4/2 上午11:05
 * @Version 1.0
 * @Attention Copyright (C), 2004-2019, BDILab, XiDian University
 **/
@RestController
@Api(tags = {"ProductRequest-企业申请金融产品功能"})
public class ProductRequestController {
    @Autowired
    ProductRequestService productRequestService;
    ResponseResult responseResult = new ResponseResult();

    @PostMapping(value = "enterprise/productRequest/{productName}")
    public ResponseResult productRequest(@RequestParam String socialCode,
                                         @PathVariable(name = "productName")String productName,
                                         @RequestParam(required=false) String fundUsage){
        try {
            productRequestService.setRequestInfo(socialCode, productName,fundUsage);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        responseResult.setSuccess(true);
        responseResult.setCode(EnterpriseCode.PRODUCT_REQUEST_SUCCESS.getCode());
        responseResult.setMessage(EnterpriseCode.PRODUCT_REQUEST_SUCCESS.getMessage());
        return responseResult;
    }
}
